<%--
  Created by IntelliJ IDEA.
  User: liuqing
  Date: 2024/11/18
  Time: 11:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.example.domain.Chapter" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ include file="header.jsp"%>

<main>
    <div class="read-container">
        <div class="read-title">
            <p>${chapter.title}</p>
        </div>
        <div class="read-nav">
            <c:choose>
                <c:when test="${chapter.chapter_id == chapterList.get(0).chapter_id}">
                    <c:set var="prevChapterId" value="${chapter.chapter_id}" />
                </c:when>
                <c:otherwise>
                    <c:set var="prevChapterId" value="${chapter.chapter_id - 1}" />
                </c:otherwise>
            </c:choose>

            <c:choose>
                <c:when test="${chapter.chapter_id == chapterList.get(chapterList.size()-1).chapter_id}">
                    <c:set var="nextChapterId" value="${chapter.chapter_id}" />
                </c:when>
                <c:otherwise>
                    <c:set var="nextChapterId" value="${chapter.chapter_id + 1}" />
                </c:otherwise>
            </c:choose>
            <a href="NovelContentServlet?chapter_id=${prevChapterId}">
                <button>上一章</button>
            </a>
            <a href="NovelDetailServlet?novel_id=${novel.novel_id}"><button>目录</button></a>
            <a><button>存书签</button></a>
            <a href="NovelContentServlet?chapter_id=${nextChapterId}">
                <button>下一章</button>
            </a>
        </div>

        <div class="read-content">
            <p>${chapter.content}</p>
        </div>
        <div>
            <div class="read-nav" style="margin-bottom: 0px">
                <a href="NovelContentServlet?chapter_id=${prevChapterId}">
                    <button>上一章</button>
                </a>
                <a href="NovelDetailServlet?novel_id=${novel.novel_id}"><button>目录</button></a>
                <a><button>存书签</button></a>
                <a href="NovelContentServlet?chapter_id=${nextChapterId}">
                    <button>下一章</button>
                </a>
            </div>
        </div>
    </div>
</main>

<%@ include file="footer.jsp"%>
